#include <generik/tracing.h>
GENERIK_TRACER_GLOBAL;

#include <iostream>

#ifdef __MINGW32__
#include <windows.h>
void run()
{
	GENERIK_TRACER;
	
	HMODULE h = LoadLibrary("./mylib.so");
	GENERIK_TRACE_VALUE(h);
	FARPROC func = GetProcAddress(h, "func");
	GENERIK_TRACE_VALUE((void*)func);
	typedef int(*plusfunc)(int, int);
	plusfunc pfunc = (plusfunc)func;
	int result = (*pfunc)(3, 4);
	GENERIK_TRACE_VALUE(result);
}
#else
#include <dlfcn.h>

void run()
{
	GENERIK_TRACER;
	
	void* lib = dlopen("./mylib.so", RTLD_LAZY);
	void* func = dlsym(lib, "func");
	
	typedef int(*plusfunc)(int, int);
	plusfunc pfunc = (plusfunc)func;
	int result = (*pfunc)(3, 4);
	
	GENERIK_TRACE_VALUE(result);
}
#endif

int main()
{
	GENERIK_TRACER;
	//std::ofstream log("blah");
	//generik::tracing::set_stream(&log);
	run();
	//generik::tracing::set_stream(&std::clog);
	return 0;
}



